import * as echarts from "../../../assets/echarts/echarts.esm.js";
export default {
    template:`<div ref="chart"></div>`,
    props: {
        options: {
            type: Object,
            default(){
                return {}
            }
        }
    },
    watch: {
        options(nv) {
            this.setOption(nv)
        }
    },
    methods: {
        initEcharts() {
            this.$chart = echarts.init(this.$refs.chart);
            this.setOption(this.options);
        },
        setOption(options){
            this.$chart.setOption(options);
        },
        showLoading(){
            this.$chart.showLoading()
        },
        hideLoading(){
            this.$chart.hideLoading();
        }
    },
    mounted () {
        this.initEcharts();
    },
}